import request from '@/utils/request'

// 列表
export function getPostList(pageNo, size, tabName) {
    return request({
		url: '/api/post/list',
		method: 'get',
		// pageNo: 页号 size: 每页显示多少帖子 tab: 显示哪种主题 (最新或最热)
		params: { pageNo: pageNo, size: size, tabName: tabName }
    })
}

// 发布
export function post(post) {
    return request({
		url: '/api/post/create',
		method: 'post',
		data: post
    })
}

// 获得帖子详情
export function fetchPostById(postId) {
	return request({
		url: `/api/post/${postId}`,
		method: 'get'
	})
}

// 获取详情页推荐 "随便看看"
export function getRecommendTopics(id) {
	return request({
		url: '/post/recommend',
		method: 'get',
		params: { topicId: id }
	})
}

// 更新帖子
export function updatePost(postUpdated) {
	return request({
		url: '/api/post/update',
		method: 'put',
		data: postUpdated
	})
}

// 删除帖子
export function deletePostById(id) {
	return request({
		url: `/api/post/delete/${id}`,
		method: 'delete'
	})
}

